"""

.. module:: delete_resource_ant_helper
.. moduleauthor:: @author: Edward Huynh

The purpose of this module is to delete a resource from the datastore. This script will be invoked through a ant task.
   
.. seealso:: modules :mod:`<module>`

*Constants*:
.. data:: constant_1
        
    constant_1 is used for ......
        
.. data:: constant_2
        
    constant_2 is used for ......
"""

from datastore.database import DataStore
from optparse import OptionParser
import os
import sys

if __name__ == '__main__':
    parser = OptionParser(usage=u"%s [<options>]" % sys.argv[0])
    parser.add_option("--id", dest=u"resource_id", type="int", help=u"Id of the existing resource to be deleted.")
    parser.add_option("--pathds", dest=u"pathds", action="store", type="string", help=u"Path to the datastore to update.")
    (options, args) = parser.parse_args()
    options.script = os.path.split(sys.argv[0])[1]
    
    ds = DataStore(options.pathds)
    ress = ds.get([options.resource_id])
    ds.delete(ress)
    print '''Resource with id {0} deleted'''.format(options.resource_id)